/****************
Replication Code for 
   Zvobgo. Kelebogile. "Demanding Truth: The Global Transitional Justice Network 
   and the Adoption of Truth Commissions." International Studies Quarterly.

Prepared for Public Posting on June 5, 2020
*****************/	

ssc install blindschemes, replace all
set scheme plottig, permanently


/****************
	STUDY ONE
*****************/	


clear all
set more off
capture log close
cap cd "/Users/kelebogilezvobgo/Dropbox/1_Research/1_Publications/6_Demanding-Truth/Demanding-Truth/ISQ_FINAL/Data"
log using "VTC_Adoption_kz2020demanding.log", replace
use "VTC_Adoption_kz2020demanding.dta", clear
pause on



***
* Descriptive Statistics
***

* Table A1: Summary Statistics of Variables Used in Study One
eststo clear
estpost summarize v2xcs_ccsi_avg5  f_media_ai_br_avg5 ingo_avg5 latentmean_avg5 lji_avg5 polconiii_avg5 region_precedent yr /*
*/igo_avg5 gdppc_wdi_avg5 oda_per_avg5 pop_wdi_avg5 duration cumulative_intensity ln_fatality /*
*/democracy_breakdowns
esttab using sumstats_studyone.tex, replace cells("mean(fmt(2)) min max count(fmt(0))") nonum noobs  label
 

* Table A5: Summary Statistics of New Variables for Varieties of Transition Supplementary Analysis
eststo clear
estpost summarize agreement victory_govt victory_rebel distributive_trans
esttab using sumstats_varieties.tex, replace cells("mean(fmt(2)) min max count(fmt(0))") nonum noobs  label
 
 
 
*** 
* Main analysis
***

* Setting global controls

global tans v2xcs_ccsi_avg5 f_media_ai_br_avg5 ingo_avg5 
global dp latentmean_avg5 lji_avg5 polconiii_avg5
global wp region_precedent yr igo_avg5 
global econ gdppc_wdi_avg5 oda_per_avg5 pop_wdi_avg5
global conflict duration cumulative_intensity
global violence ln_fatality
global democracy democracy_breakdowns

* Table 1: Transnational Advocacy and Truth Commission Creation
eststo clear
eststo A: logit tc_10 $tans $dp dem conflict, vce(cluster gwno)
eststo B: logit tc_10 $tans $dp $wp dem conflict, vce(cluster gwno)
eststo C: logit tc_10 $tans $dp $wp $econ dem conflict, vce(cluster gwno)
eststo D: logit tc_10 $tans $dp $wp $econ $conflict, vce(cluster gwno)
eststo E: logit tc_10 $tans $dp $wp $econ $violence, vce(cluster gwno)
eststo F: logit tc_10 $tans $dp $wp $econ $democracy, vce(cluster gwno)
esttab A B C D E F using study_one.tex, replace unstack label b(2) se(2) /*
*/ nomtitles title("Transnational Advocacy and Truth Commission Adoption") /*
*/ addnotes("All models report clustered standard errors by country.") star(+ 0.10 * 0.05 ** 0.01) 



*** 
* Robustness checks and supplementary analyses
***

* Table A4: Transnational Advocacy and Truth Commission Creation (transition = 5 years)
eststo clear
eststo A: logit tc_5 $tans $dp dem conflict, vce(cluster gwno)
eststo B: logit tc_5 $tans $dp $wp dem conflict, vce(cluster gwno)
eststo C: logit tc_5 $tans $dp $wp $econ dem conflict, vce(cluster gwno)
eststo D: logit tc_5 $tans $dp $wp $econ $conflict, vce(cluster gwno)
eststo E: logit tc_5 $tans $dp $wp $econ $violence, vce(cluster gwno)
eststo F: logit tc_5 $tans $dp $wp $econ $democracy, vce(cluster gwno)
esttab A B C D E F using study_one_5y.tex, replace unstack label b(2) se(2) /*
*/ nomtitles title("Transnational Advocacy and Truth Commission Adoption (transition = 5 years)") /*
*/ addnotes("All models report clustered standard errors by country.") star(+ 0.10 * 0.05 ** 0.01) 


* Table A6: Truth Commission Creation, by Conflict Termination Type
eststo clear
eststo D: logit tc_10 $tans $dp $wp $econ $conflict, vce(cluster gwno)
eststo winner: logit tc_10 $tans $dp $wp $econ $conflict agreement victory_govt victory_rebel, vce(cluster gwno)
esttab D winner using reg_conflict.tex, replace wide  label b(2) se(2) /*
*/ nomtitles title("Truth Commission Adoption, by Conflict Termination Type") /*
*/ addnotes("All models report clustered standard errors by country.") star(+ 0.10 * 0.05 ** 0.01) 


* Table A7: Truth Commission Creation, by Regime Transition Type
eststo clear
eststo F: logit tc_10 $tans $dp $wp $econ $democracy, vce(cluster gwno)
eststo hkt_dist: logit tc_10 $tans $dp $wp $econ $democracy distributive_trans, vce(cluster gwno)
esttab F hkt_dist using reg_democracy.tex, replace wide label b(2) se(2) /*
*/ nomtitles title("Truth Commission Adoption, by Regime Transition Type") /*
*/ addnotes("All models report clustered standard errors by country.") star(+ 0.10 * 0.05 ** 0.01) 


* Table A8:  Single Observation Survival Analysis for Truth Commission Creation >> See R files


* Table A9: Truth Commission Creation, with Interaction Effects
eststo C: logit tc_10 $tans $dp $wp $econ dem conflict, vce(cluster gwno)
eststo interaction: logit tc_10 $tans $dp $wp $econ dem conflict domestic_shaming, vce(cluster gwno)
esttab C interaction using interaction.tex, replace wide  label b(2) se(2) /*
*/ nomtitles title("Truth Commission Adoption, by Conflict Termination Type") /*
*/ addnotes("All models report clustered standard errors by country.") star(+ 0.10 * 0.05 ** 0.01) 



***
* Correlation Test: Independent Variables
***
corr v2xcs_ccsi_avg5 ingo_avg5
corr ingo_avg5 f_media_ai_br_avg5
corr v2xcs_ccsi_avg5 f_media_ai_br_avg5



***
* Table A2:  Nearest Neighbor Matching
***

eststo NNM1: teffects nnmatch (tc_10 $tans $dp $wp $econ) (dem), biasadj($tans $dp $wp $econ) vce(iid)
eststo NNM2:  teffects nnmatch (tc_10 $tans $dp $wp $econ) (conflict), biasadj($tans $dp $wp $econ) vce(iid)

esttab NNM1 NNM2 using nnm_.tex, replace  label b(2) se(2) /*
*/ nomtitles title("Nearest-Neighbor Matching") /*
*/ addnotes("All models report clustered standard errors by country.") star(+ 0.10 * 0.05 ** 0.01)  



*** 
* Predicted Effects, Substantive Effects, Figures
***

*remove LaTeX formatting for labels for logged variables
label variable ingo_avg5 "Network Access (ln)"
label variable igo_avg5 "IGO Membership (ln)"
label variable gdppc_wdi_avg5 "GDP per capita (ln)"
label variable oda_per_avg5 "ODA as % of GDP"
label variable pop_wdi_avg5 "Population (ln)"
label variable ln_fatality "Civilian Killings (ln)"


* Coefficient Plot 

* Figure 3: Predicted Effect of Variables on the Likelihood of Truth Commissions
sem (tc_10 <- $tans $dp $wp $econ dem conflict, vce(cluster gwno))
coefplot, drop(_cons) xline(0) b(b_std) v(V_std) xtitle(Standardized Coefficients) level(95)
graph export "/Users/kelebogilezvobgo/Dropbox/1_Research/1_Publications/6_Demanding-Truth/Demanding-Truth/ISQ_FINAL/Data/standardized_main_coefplot.eps", replace


* Marginal Effects and Plots 
logit tc_10 $tans $dp $wp $econ dem conflict, vce(cluster gwno)

* Figure 4: Effect of Strong Domestic Civil Society, with 95% CIs
margins, at(v2xcs_ccsi_avg5=(0(.1)1))
marginsplot, graphregion(fcolor(white)) recast(scatter) ytitle("Pr(TruthCommission)", size(small)) title("", size(small))
graph export "/Users/kelebogilezvobgo/Dropbox/1_Research/1_Publications/6_Demanding-Truth/Demanding-Truth/ISQ_FINAL/Data/margins_robust_cs.eps", replace

* Figure 5: Effect of INGO Naming and Shaming, with 95% CIs 
margins, at(f_media_ai_br_avg5=(0(5)36))
marginsplot, graphregion(fcolor(white)) recast(scatter) ytitle("Pr(TruthCommission)", size(small)) title("", size(medium small))
graph export "/Users/kelebogilezvobgo/Dropbox/1_Research/1_Publications/6_Demanding-Truth/Demanding-Truth/ISQ_FINAL/Data/margins_ai_br.eps", replace

* Figure 6: Effect of Network Access, with 95% CIs
margins, at(ingo_avg5=(0(1)8))
marginsplot, graphregion(fcolor(white)) recast(scatter)  ytitle("Pr(TruthCommission)", size(small)) title("", size(medium small))
graph export "/Users/kelebogilezvobgo/Dropbox/1_Research/1_Publications/6_Demanding-Truth/Demanding-Truth/ISQ_FINAL/Data/margins_network.eps", replace





/****************
	STUDY TWO	
*****************/	

clear all
set more off
capture log close
cap cd "/Users/kelebogilezvobgo/Dropbox/1_Research/1_Publications/6_Demanding-Truth/Demanding-Truth/ISQ_FINAL/Data"
log using "VTC_Design_kz2020demanding.log", replace
use "VTC_Design_kz2020demanding.dta", clear
pause on



***
* Descriptive Statistics
***

* Table 2: Summary Statistics of Dependent Variables Used in Study Two

eststo clear
estpost summarize violations_broad scope_broad subpoena preserve_evidence
esttab using sumstats_DV.tex, replace cells("mean(fmt(2)) min max count(fmt(0))") nonum noobs  label

* Table A3: Summary Statistics of Independent Variables Used in Study Two

eststo clear
estpost summarize ictj v2xcs_ccsi_avg5  authoritarian_govt civil_war /*
*/ precedent_scope precedent_violations_broad precedent_subpoena precedent_preserve_evidence /*
*/ yr democracy transitional
esttab using sumstats_IV.tex, replace cells("mean(fmt(2)) min max count(fmt(0))") nonum noobs  label



*** 
* Main analysis
***

* Setting Global Controls

global violence_type  authoritarian_govt civil_war
global domestic_politics  transitional democracy
 

*This makes Table 3: ICTJ Involvement and Truth Commission Powers

eststo clear
eststo A: logit violations_broad ictj v2xcs_ccsi_avg5 $violence_type $precedents $domestic_politics yr precedent_violations_broad, vce(cluster gwno)
eststo B: logit scope_broad ictj v2xcs_ccsi_avg5 $violence_type $precedents $domestic_politics yr  precedent_scope, vce(cluster gwno) /**/
eststo C: logit subpoena ictj v2xcs_ccsi_avg5 $violence_type $precedents $domestic_politics yr precedent_subpoena, vce(cluster gwno) /**/
eststo D: logit preserve_evidence ictj v2xcs_ccsi_avg5 $violence_type $precedents $domestic_politics yr precedent_preserve_evidence, vce(cluster gwno) /**/
esttab A B C D using study_two.tex, replace unstack label b(2) se(2) /*
*/ nomtitles title("ICTJ Involvement and Truth Commission Powers") /*
*/ addnotes("All models report clustered standard errors by country.") star(+ 0.10 * 0.05 ** 0.01) 



*** 
* Predicted Effects, Substantive Effects, Figures
***

* Coefficient Plots - Figure 8: Effect of ICTJ Involvement, with 95% CIs

sem (violations_broad <- ictj v2xcs_ccsi_avg5 $violence_type $precedents $domestic_politics yr  precedent_violations_broad, vce(cluster gwno))
coefplot, drop(_cons) xline(0) b(b_std) v(V_std) xtitle(Standardized Coefficients) level(95)
graph export "/Users/kelebogilezvobgo/Dropbox/1_Research/1_Publications/6_Demanding-Truth/Demanding-Truth/ISQ_FINAL/Data/margins_abuses.eps", replace

sem (scope_broad <- ictj v2xcs_ccsi_avg5 $violence_type $precedents $domestic_politics yr  precedent_scope, vce(cluster gwno))
coefplot, drop(_cons) xline(0) b(b_std) v(V_std) xtitle(Standardized Coefficients) level(95)
graph export "/Users/kelebogilezvobgo/Dropbox/1_Research/1_Publications/6_Demanding-Truth/Demanding-Truth/ISQ_FINAL/Data/margins_antecedents.eps", replace

sem (subpoena <- ictj v2xcs_ccsi_avg5 $violence_type $precedents $domestic_politics yr  precedent_subpoena, vce(cluster gwno))
coefplot, drop(_cons) xline(0) b(b_std) v(V_std) xtitle(Standardized Coefficients) level(95)
graph export "/Users/kelebogilezvobgo/Dropbox/1_Research/1_Publications/6_Demanding-Truth/Demanding-Truth/ISQ_FINAL/Data/margins_subpoena.eps", replace

sem (preserve_evidence <- ictj v2xcs_ccsi_avg5 $violence_type $precedents $domestic_politics yr  precedent_preserve_evidence, vce(cluster gwno))
coefplot, drop(_cons) xline(0) b(b_std) v(V_std) xtitle(Standardized Coefficients) level(95)
graph export "/Users/kelebogilezvobgo/Dropbox/1_Research/1_Publications/6_Demanding-Truth/Demanding-Truth/ISQ_FINAL/Data/margins_evidence.eps", replace


* Marginal Effects

logit scope_broad ictj v2xcs_ccsi_avg5 $violence_type $precedents $domestic_politics yr  precedent_scope, vce(cluster gwno)
margins, at(ictj=(0 1))
logit preserve_evidence ictj v2xcs_ccsi_avg5 $violence_type $precedents $domestic_politics yr precedent_preserve_evidence, vce(cluster gwno) /**/
margins, at(ictj=(0 1))


